package com.project.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.project.util.ValidAdd;

import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.List;

@TableName("t_post")
public class PostBean {
    @TableId(value = "pk_postId",type = IdType.AUTO)
    private Integer id;
    @TableField("fk_channelId")
    private Integer channelId;
    @TableField("p_title")
    @NotBlank(groups = ValidAdd.class,message = "标题不能为空")
    private String title;
    @TableField("fk_userId")
    private Integer userId;
    @TableField(exist = false)
    private UserBean user;
    @TableField("p_content")
    @NotBlank(groups = ValidAdd.class, message = "内容不能为空")
    private String content;
    @TableField("p_time")
    private LocalDateTime time=LocalDateTime.now();
    @TableField(exist = false)
    private Integer replayNum;
    @TableField(exist = false)
    private List<ReplayBean> replayList;

    public PostBean() {
    }

    public PostBean(Integer channelId, String title, Integer userId, String content) {
        this.channelId = channelId;
        this.title = title;
        this.userId = userId;
        this.content = content;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getChannelId() {
        return channelId;
    }

    public void setChannelId(Integer channelId) {
        this.channelId = channelId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public UserBean getUser() {
        return user;
    }

    public void setUser(UserBean user) {
        this.user = user;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public LocalDateTime getTime() {
        return time;
    }

    public void setTime(LocalDateTime time) {
        this.time = time;
    }

    public Integer getReplayNum() {
        return replayNum;
    }

    public void setReplayNum(Integer replayNum) {
        this.replayNum = replayNum;
    }

    public List<ReplayBean> getReplayList() {
        return replayList;
    }

    public void setReplayList(List<ReplayBean> replayList) {
        this.replayList = replayList;
    }

    @Override
    public String toString() {
        return "PostBean{" +
                "id=" + id +
                ", channelId=" + channelId +
                ", title='" + title + '\'' +
                ", userId=" + userId +
                ", user=" + user +
                ", content='" + content + '\'' +
                ", time=" + time +
                ", replayNum=" + replayNum +
                ", replayList=" + replayList +
                "}\n";
    }
}
